package com.zry.fertilizer.ui.activity

import android.annotation.SuppressLint
import com.bumptech.glide.Glide
import com.zry.fertilizer.R
import com.zry.fertilizer.been.StockProduct
import com.zry.fertilizer.databinding.ActivityStockProductInfoBinding
import com.zry.fertilizer.glide.GlideLoadPhoto
import com.zry.fertilizer.ui.base.BaseActivity
import com.zry.fertilizer.utils.UIUtil
import kotlinx.android.synthetic.main.activity_stock_product_info.*
import kotlinx.android.synthetic.main.common_title.*

class StockProductInfoActivity : BaseActivity() {
    private var stockProductBean: StockProduct? = null
    private var stockProductInfoBinding: ActivityStockProductInfoBinding? = null
    override fun getLayoutId(): Int {
        return R.layout.activity_stock_product_info
    }

    @SuppressLint("SetTextI18n")
    override fun initData() {

        titleCenterText.text = "产品信息"
        commonLeftLinearLayout.setOnClickListener { finish() }

        stockProductBean = intent.getSerializableExtra("StockProduct") as StockProduct
        stockProductInfoBinding = viewDataBinding as ActivityStockProductInfoBinding
        stockProductInfoBinding?.stockProduct = stockProductBean


        UIUtil.setWidgetHeight(stockProductImgLinear, UIUtil.getScreenWidth(this) * 800 / 1080)
        UIUtil.setWidgetHeight(stockProductImg, UIUtil.getScreenWidth(this) * 500 / 1080)
        UIUtil.setWidgetWidth(stockProductImg, UIUtil.getScreenWidth(this) * 500 / 1080)
        Glide.with(this).load(stockProductBean!!.ProductImage).apply(GlideLoadPhoto().GlideLoadImg(R.mipmap.ic_launcher, R.mipmap.ic_launcher)).into(stockProductImg)

        when (stockProductBean?.StockType) {
            "1" -> {
                stockPutStorageType.text = "单码入库"
                productInfoPackRadioTV.text = "——"
            }
            "2" -> {
                productInfoPackRadioTV.text = stockProductBean!!.PackRadio
                stockPutStorageType.text = "二级码入库"
            }
            "3" -> {
                productInfoPackRadioTV.text = stockProductBean!!.PackRadio
                stockPutStorageType.text = "三级码入库"
            }
        }

        stockProductInfoExpiryDate.text=stockProductBean!!.ExpiryDate+"月"


    }
}
